package com.laoniu.service;

import com.google.common.collect.Maps;
import com.laoniu.enums.ServiceTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

@Service
public class SelectService {

    @Autowired
    private List<CommonService> commonServices;

    private Map<ServiceTypeEnum, CommonService> serviceMap;

    @PostConstruct
    private void postCut(){
        serviceMap = Maps.newHashMap();
        commonServices.forEach(service -> {
            serviceMap.put(service.getType(), service);
        });
    }

    public String getTestMethod(ServiceTypeEnum typeEnum){
        return serviceMap.get(typeEnum).testMethod();
    }
}
